package com.huilian.iotbox.data.cmd;

import com.huilian.iotbox.data.constants.IotConstant;
import com.huilian.iotbox.data.utils.IotBoxUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.RandomStringUtils;

import java.math.BigDecimal;

/**
 * 超级兑币机主动下发帧
 *
 * @author chenqiwen
 * @CreateDate: 2022-04-25-11-00
 * @Description:
 */
@Slf4j
public class HuiLianDuiBiJiPositiveDataFrameCMD {

    /**
     * 已绑定设备或解绑设备或编辑套餐，给设备信号
     *
     * @return
     */
    public static String boundDeviceOrUnBindOrEditDiscountPackage() {

        StringBuilder stringBuilder = new StringBuilder(IotConstant.CONTENT_PREFIX);
        StringBuilder dataPrefix = new StringBuilder("0401D115");

        stringBuilder
                .append(dataPrefix)
                .append(IotBoxUtil.checkcode_0007(dataPrefix.toString()))
                .append(IotConstant.CONTENT_SUFFIX);
        return stringBuilder.toString().toUpperCase();
    }

    /**
     * 通知兑币机主动上报日志文件名称列表
     *
     * @return
     */
    public static String notificationActiveReporting(Integer dirIndex) {

        StringBuilder stringBuilder = new StringBuilder(IotConstant.CONTENT_PREFIX);
        StringBuilder dataPrefix = new StringBuilder("0400D122")
                .append(IotBoxUtil.singleInt2Hex(dirIndex));

        stringBuilder
                .append(dataPrefix)
                .append(IotBoxUtil.checkcode_0007(dataPrefix.toString()))
                .append(IotConstant.CONTENT_SUFFIX);
        return stringBuilder.toString().toUpperCase();
    }


    /**
     * 通知兑币机主动上传某个日志文件
     *
     * @param index 日志文件下标
     * @return
     */
    public static String notificationActiveReportingLogFile(Integer dirIndex, int index) {

        StringBuilder stringBuilder = new StringBuilder(IotConstant.CONTENT_PREFIX);
        StringBuilder dataPrefix = new StringBuilder("0500D123")
                .append(IotBoxUtil.singleInt2Hex(dirIndex))
                .append(IotBoxUtil.singleInt2Hex(index));

        stringBuilder
                .append(dataPrefix)
                .append(IotBoxUtil.checkcode_0007(dataPrefix.toString()))
                .append(IotConstant.CONTENT_SUFFIX);
        return stringBuilder.toString().toUpperCase();
    }

    /**
     * 通知兑币机会员登录用户
     *
     * @param memberStoreBalanceId 会员Id
     * @return
     */
    public static String noticeAppLoginMember(Long memberStoreBalanceId) {

        StringBuilder stringBuilder = new StringBuilder(IotConstant.CONTENT_PREFIX);
        StringBuilder dataPrefix = new StringBuilder("0500D124")
                .append(IotBoxUtil.singleInt2Hex(memberStoreBalanceId.intValue()));

        stringBuilder
                .append(dataPrefix)
                .append(IotBoxUtil.checkcode_0007(dataPrefix.toString()))
                .append(IotConstant.CONTENT_SUFFIX);
        return stringBuilder.toString().toUpperCase();
    }
}
